require 'test/unit'
require 'Modele/Parking'
require 'Modele/Vehicule'
require 'Modele/Client'
require 'Modele/Client_garanti'
require 'Modele/Dbconect'

class Client_garantiTest < Test::Unit::TestCase
  
  def test_garer_ok
    Dbconect.creationbd("test")
    parking = Parking.new("test",3)
    vehicule= Vehicule.new("123ABC31")
    client =Client_garanti.new("Folgueral","Thomas",parking)
    assert(/[0-9]/.match(client.se_garer(vehicule,parking.acces[0].borne)) != nil,"test_garer_ok fail")
  end
  
  def test_garer_plein_ok
    Dbconect.creationbd("test")
    parking = Parking.new("test",0)
    vehicule= Vehicule.new("123ABC31")
    client =Client_garanti.new("Folgueral","Thomas",parking)
    assert(/[0-9]/.match(client.se_garer(vehicule,parking.acces[0].borne)) != nil,"test_garer_pas_ok fail")
  end
  
  
  def test_reprendre_vehicule_ok
    Dbconect.creationbd("test")
    parking = Parking.new("test",3)
    vehicule= Vehicule.new("123ABC31")
    client =Client_garanti.new("Folgueral","Thomas",parking)
    client.se_garer(vehicule,parking.acces[0].borne)
    ticket = parking.get_place_by_vehicule("123ABC31").ticket
    assert(client.reprendre_vehicule(ticket,parking.acces[0].borne) != nil,"test_reprendre_vehicule_ok fail")
  end
  
  def test_reprendre_vehicule_pas_ok_immat
     Dbconect.creationbd("test")
     parking = Parking.new("test",3)
     vehicule= Vehicule.new("123ABC31")
     client =Client_garanti.new("Folgueral","Thomas",parking)
     client.se_garer(vehicule,parking.acces[0].borne)
     ticket = parking.get_place_by_vehicule("123ABC30").ticket if parking.get_place_by_vehicule("123ABC30")
     assert(client.reprendre_vehicule(ticket,parking.acces[0].borne) == nil,"test_reprendre_vehicule_ok fail")
  end
 
 def test_reprendre_vehicule_pas_ok_vehicule
    Dbconect.creationbd("test")
    parking = Parking.new("test",3)
    client =Client_garanti.new("Folgueral","Thomas",parking)    
    ticket = parking.get_place_by_vehicule("123ABC31").ticket if parking.get_place_by_vehicule("123ABC31")
    assert(client.reprendre_vehicule(ticket,parking.acces[0].borne) == nil,"test_reprendre_vehicule_ok fail")
 end
  
end